//
// Decompiled by Jadx - 469ms
//
package me.plusne.Adapter.Login;

import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import fg.t;
import fn.b;
import java.util.ArrayList;
import me.plusne.common.Json.Login.JsonLoginQuerySet;
import r.f;

public final class HookSetListAdapter extends RecyclerView.h<a> {
    public static boolean a;
    public String b;
    public final Activity c;
    public final JsonLoginQuerySet d;
    public String f;
    public final ArrayList e = new ArrayList();
    public boolean g = true;

    public HookSetListAdapter(Activity activity, JsonLoginQuerySet jsonLoginQuerySet) {
        this.d = jsonLoginQuerySet;
        this.c = activity;
    }

    public final int getItemCount() {
        JsonLoginQuerySet jsonLoginQuerySet = this.d;
        if (jsonLoginQuerySet == null) {
            return 0;
        }
        ArrayList arrayList = this.e;
        arrayList.clear();
        if (!TextUtils.isEmpty(this.b)) {
            for (JsonLoginQuerySet.SetBean setBean : jsonLoginQuerySet.getSet()) {
                if (setBean.getTitle().toLowerCase().contains(this.b) || setBean.getDesc().toLowerCase().contains(this.b)) {
                    arrayList.add(setBean);
                }
            }
            if (arrayList == null) {
                return 0;
            }
            return arrayList.size();
        }
        if (this.g) {
            if (jsonLoginQuerySet.getGroup() == null) {
                return 0;
            }
            return jsonLoginQuerySet.getGroup().size();
        }
        for (JsonLoginQuerySet.SetBean setBean2 : jsonLoginQuerySet.getSet()) {
            if (setBean2.getUuid().equals(this.f)) {
                arrayList.add(setBean2);
            }
        }
        if (arrayList == null) {
            return 0;
        }
        return arrayList.size();
    }

    /* JADX WARN: Failed to find 'out' block for switch in B:20:0x009f. Please report as an issue. */
    public final void onBindViewHolder(RecyclerView.ae aeVar, int i) {
        boolean z;
        Object obj;
        View view;
        d tVar;
        a aVar = (a) aeVar;
        if (this.g && TextUtils.isEmpty(this.b)) {
            z = true;
        } else {
            z = false;
        }
        if (z) {
            obj = this.d.getGroup().get(i);
        } else {
            obj = this.e.get(i);
        }
        aVar.getClass();
        int i2 = i + 1;
        int itemCount = getItemCount();
        View view2 = aVar.b;
        if (i2 == itemCount) {
            view2.setVisibility(View.GONE);
        } else {
            view2.setVisibility(View.VISIBLE);
        }
        ImageView imageView = aVar.g;
        imageView.setOnClickListener(null);
        ((RecyclerView.ae) aVar).itemView.setOnClickListener(null);
        ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(null);
        Switch r4 = aVar.f;
        r4.setOnCheckedChangeListener(null);
        TextView textView = aVar.e;
        textView.setVisibility(View.GONE);
        TextView textView2 = aVar.d;
        textView2.setVisibility(View.GONE);
        boolean z2 = obj instanceof JsonLoginQuerySet.SetBean;
        TextView textView3 = aVar.c;
        ImageView imageView2 = aVar.h;
        if (z2) {
            JsonLoginQuerySet.SetBean setBean = (JsonLoginQuerySet.SetBean) obj;
            textView3.setText(setBean.getTitle());
            if (!TextUtils.isEmpty(setBean.getDesc())) {
                textView2.setVisibility(View.VISIBLE);
                textView2.setText(setBean.getDesc());
            }
            if (!TextUtils.isEmpty(setBean.getHelp())) {
                imageView.setVisibility(View.VISIBLE);
                imageView.setOnClickListener(new t(1, this, setBean));
            } else {
                imageView.setVisibility(View.GONE);
            }
            switch (setBean.getType()) {
                case 0:
                    imageView2.setVisibility(View.GONE);
                    r4.setVisibility(View.VISIBLE);
                    r4.setChecked(b.h(setBean.getKey(), true ^ TextUtils.isEmpty(setBean.getDefaultValue())));
                    r4.setOnCheckedChangeListener(new e(aVar, setBean, this));
                    return;
                case 1:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    if (!TextUtils.isEmpty(b.g(setBean.getKey(), ""))) {
                        textView.setVisibility(View.VISIBLE);
                        textView.setText(b.g(setBean.getKey(), ""));
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 4));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 4);
                    break;
                case 2:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    try {
                        if (!TextUtils.isEmpty(b.g(setBean.getKey(), ""))) {
                            textView.setVisibility(View.VISIBLE);
                            textView.setText(b.g(setBean.getKey(), ""));
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        f.i().l(e.getMessage());
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 5));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 5);
                    break;
                case 3:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    if (!TextUtils.isEmpty(b.g(setBean.getKey(), ""))) {
                        textView.setVisibility(View.VISIBLE);
                        textView.setText(b.g(setBean.getKey(), ""));
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 6));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 6);
                    break;
                case 4:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    if (!TextUtils.isEmpty(b.g(setBean.getKey() + "_text", ""))) {
                        textView.setVisibility(View.VISIBLE);
                        textView.setText(b.g(setBean.getKey() + "_text", ""));
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 7));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 7);
                    break;
                case 5:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    if (!TextUtils.isEmpty(b.g(setBean.getKey(), ""))) {
                        textView.setVisibility(View.VISIBLE);
                        textView.setText(b.g(setBean.getKey(), ""));
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 0));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 0);
                    break;
                case 6:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    if (!TextUtils.isEmpty(b.g(setBean.getKey(), ""))) {
                        textView.setVisibility(View.VISIBLE);
                        textView.setText(b.g(setBean.getKey(), ""));
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 1));
                    ((RecyclerView.ae) aVar).itemView.setOnClickListener(new d(aVar, setBean, this, 1));
                    return;
                case 7:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    if (!TextUtils.isEmpty(b.g(setBean.getKey(), ""))) {
                        textView.setVisibility(View.VISIBLE);
                        textView.setText(b.g(setBean.getKey(), ""));
                    }
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 2));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 2);
                    break;
                case 8:
                    imageView2.setVisibility(View.VISIBLE);
                    r4.setVisibility(View.GONE);
                    textView.setVisibility(View.VISIBLE);
                    textView.setText(String.valueOf(b.f(0, setBean.getKey())));
                    ((RecyclerView.ae) aVar).itemView.setOnLongClickListener(new c(aVar, setBean, this, 3));
                    view = ((RecyclerView.ae) aVar).itemView;
                    tVar = new d(aVar, setBean, this, 3);
                    break;
                default:
                    return;
            }
        } else {
            JsonLoginQuerySet.GroupBean groupBean = (JsonLoginQuerySet.GroupBean) obj;
            textView3.setText(groupBean.getTitle());
            imageView2.setVisibility(View.VISIBLE);
            textView2.setVisibility(View.GONE);
            textView.setVisibility(View.GONE);
            imageView.setVisibility(View.GONE);
            r4.setVisibility(View.GONE);
            view = ((RecyclerView.ae) aVar).itemView;
            tVar = new t(2, groupBean, this);
        }
        view.setOnClickListener(tVar);
    }

    public final RecyclerView.ae onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new a(this, LayoutInflater.from(viewGroup.getContext()).inflate(-2113142701, viewGroup, false));
    }
}
